Expose Management API rate limit info via a client callback - #774
Open
ProdigyTom wants to merge 1 commit into
Open
Expose Management API rate limit info via a client callback#774ProdigyTom wants to merge 1 commit into
ProdigyTom wants to merge 1 commit into
Conversation
Contributor
|
@ProdigyTom I can see some merge conflicts. Can you please resolve them? Post that I can take a look |
8 tasks
Exposes Auth0's rate limit info (x-ratelimit-limit / -remaining / -reset) from every Management API response via an opt-in callback, so callers can monitor how close they are to the limit (per auth0#606). - Add Auth0::Internal::Http::RateLimit (limit/remaining/reset; blank and non-numeric header values become nil rather than 0) - RawClient gains a rate_limit_handler, invoked in #send after retries on every response; handler errors are swallowed so they can't break a request. #send's return value is unchanged, so generated callers are unaffected. - Wire it through the custom client: Auth0::Client.new(management_rate_limit_handler:) attaches the handler to the management raw client - Unit tests for RateLimit, RawClient#send handler behavior, and client wiring All changes live in fernignored files, so they survive regeneration. Refs auth0#606.
ProdigyTom
force-pushed
the
feat/expose-rate-limit-data
branch
from
September 2, 2026 13:39
1943366 to
f119645
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Exposes Auth0's rate-limit information (
x-ratelimit-limit/-remaining/-reset) from every Management API response, so callers can monitor how close they are to the limit (the ask in #606). It's delivered via an opt-in callback rather than a changed return value — see the note below on why.Auth0::Internal::Http::RateLimit— value object (limit,remainingas Integers;resetas a UTCTime). Blank/non-numeric header values becomenil(never a misleading0).RawClientgains an optionalrate_limit_handler, invoked in#sendafter retries on every response with the parsedRateLimit. Handler errors are swallowed so a monitoring callback can never break a request.#send's return value is unchanged, so the generated callers are unaffected.Auth0::Client.new(..., management_rate_limit_handler: ->(rl) { ... })attaches the handler to the management raw client.lib/auth0/internal/**,lib/auth0/mixins/**,lib/auth0/auth_client.rb), so they survive regeneration.RateLimit,RawClient#sendhandler behavior, and the client wiring.Why a callback instead of returning the rate limit (e.g.
with_raw_response)? The generated endpoint methods (Auth0::Users::Client#get, etc.) parse the body and discard the response, and they're regenerated — so a third-party change to what they return wouldn't survive. A callback invoked at the maintainedRawClientlayer is the part we can change durably while still delivering the data on every request. If you'd prefer to also expose it as a return value via a generatedwith_raw_response-style accessor, thisRateLimitobject slots right in — happy to align.References
Testing
Unit tests under
test/unit/cover header parsing (0vs blank/non-numeric), the handler firing with the parsed rate limit while the response is returned unchanged, handler errors not breaking the request, and the client wiring. Fullrake testpasses locally with no failures.Checklist